/*
 * @Author: xiaosihan 
 * @Date: 2022-12-07 21:34:38 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2023-01-03 23:43:35
 */

import { Color, DoubleSide, EquirectangularReflectionMapping, MeshBasicMaterial, MeshPhongMaterial, MeshPhysicalMaterial } from "three";
import skyMap from "./bluesky.jpg";
import threeLoader from "three-base/threeLoader";

// 公共材质
const publicMaterial = {
    // 透明蓝色材质
    transparentBlue: new MeshBasicMaterial({
        transparent: true,
        opacity: 0.1,
        color: new Color("#66aaff"),
        // color: "#4E83D9",
        // color: "#7a9cd2",
        // specularColor: new Color("#7a9cd2"),
        side: DoubleSide,
        // roughness: 0.6,
        // metalness: 0.8
    }),

    // 透明蓝色材质2
    transparentBlue2: new MeshPhysicalMaterial({
        transparent: true,
        opacity: 0.9,
        // color: "#4E83D9",
        color: new Color("#7a9cd2").multiplyScalar(0.3),
        // specularColor: new Color("#53648D"),
        side: DoubleSide,
        // roughness: 0.5,
        // metalness: 0.8
    }),

    // 玻璃的材质
    glassMat: (() => {
        // 环境贴图
        const envMap = threeLoader.getTexture(skyMap).clone();
        envMap.mapping = EquirectangularReflectionMapping;

        const envMat = new MeshPhongMaterial({
            color: "#666",
            side: DoubleSide,
            transparent: true,
            opacity: 0.8,
            envMap,
            // envMapIntensity: 1,
            // reflectivity: 1,
            // roughness: 0,
            // metalness: 1
        });

        return envMat;
    })()
}

export default publicMaterial;

